﻿package de.gameduell.framework.game.billard.model {
	import org.cove.ape.AbstractParticle;	
	import org.cove.ape.Quaternion;
	import org.cove.ape.SphereParticle;
	import org.cove.ape.Vector;		

	/**
	 * @author cbra
	 */
	public class AnimationStep {
		private var _position:Vector;
		private var _velocity:Vector;
		private var _rotation:Quaternion;
		private var _collided:Boolean;
		private var _stopped:Boolean;
		private var _hole:Hole;
		private var _removed:Boolean;
		private var _fallen:Boolean;
		private var _collidedParticles:Array;
		private var _collisionPosition:Vector = null;

		public function AnimationStep(ball:Ball) {		
			_position = new Vector();
			_position.copy(ball.position);
			_collided = ball.collidedParticles.length > 0;
			_rotation = ball.rotation.clone();
			_stopped  = ball.isStopped();
			_hole     = ball.hole;
			_removed  = ball.removed;
			_fallen   = ball.fallen;
			_velocity = ball.velocity.clone();
			if(ball.collisionPosition != null){
				_collisionPosition = ball.collisionPosition.clone();
			}
			_collidedParticles = ball.collidedParticles.slice();
		}

		public function get removed():Boolean{
			return _removed;
		}
		
		public function get fallen():Boolean{
			return _fallen;
		}
		
		public function get hole():Hole{
			return _hole;
		}
		
		public function get isStopped():Boolean{
			return _stopped;
		}
		
		public function set position(aPos:Vector):void{
			_position = aPos;
		}	
		
		public function get velocity():Vector{
			return _velocity;
		}

		public function get position():Vector{
			return _position;
		}
		
		public function get rotation():Quaternion{
			return _rotation;
		}
		
		public function get collided():Boolean{
			return _collided;
		}
		
		public function get collisionPosition():Vector{
			return _collisionPosition;
		}
		
		public function get collidedParticles():Array{
			return _collidedParticles;
		}
		
		public function toString():String{
			return "\n removed: "+_removed + "\n fallen: "+ _fallen + " \n isStopped: "+_stopped + "\n collided: "+_collided +"\n position: "+ _position + " \n rotation: " + _rotation ;
		}
	}
}
